{include file="public/header" /}





<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>{$Think.lang.ds_wholesale}</h3>
                <h5></h5>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>
  <div class="homepage-focus" dstype="editStoreContent">
      <ul class="tab-menu">
          <li class="current">{$Think.lang.store_info}</li>
          <li>{$Think.lang.register_info}</li>
          <li>{$Think.lang.credit_num}</li>
      </ul>
      <form id="store_form" method="post">
          <input type="hidden" name="store_id" value="{$store_array.store_id}" />
          <table class="ds-default-table">
              <tbody>
              <!--店主账号-->
              <tr class="noborder">
                  <td class="required w120"><label class="validation" for="store_name">{$Think.lang.store_user_name}:</label></td>
                  <td class="vatop rowform">{$store_array.member_name}</td>
                  <td class="vatop tips"></td>
              </tr>
              <!--卖家账号-->
              <tr class="noborder">
                  <td class="required w120"><label class="validation" for="store_name">{$Think.lang.ds_seller_name}:</label></td>
                  <td class="vatop rowform">{$store_array.seller_name}</td>
                  <td class="vatop tips">{$Think.lang.store_seller_name_tips}</td>
              </tr>
              <!--供货商名称-->
              <tr class="noborder">
                  <td class="required w120"><label class="validation" for="store_name">{$Think.lang.ds_store_name}:</label></td>
                  <td class="vatop rowform"><input type="text" value="{$store_array.store_name}" id="store_name" name="store_name" class="txt"></td>
                  <td class="vatop tips"></td>
              </tr>
                <!--开店时间-->
              <tr class="noborder">
                  <td class="w120"><label class="validation" for="store_name">{$Think.lang.store_addtime}:</label></td>
                  <td class="vatop rowform">{notempty name="$store_array.store_addtime"}{$store_array.store_addtime|date='Y-m-d',###}{/notempty}</td>
                  <td class="vatop tips"></td>
              </tr>
              <!--供货商类型-->
              <tr class="noborder">
                  <td class="required w120"><label class="validation" for="store_name">{$Think.lang.store_type}:</label></td>
                  <td class="vatop rowform">
                      <select name="store_type" id="store_type">
                          <option value="0">请选择</option>
                          {notempty name="class_list"}
                          {foreach $class_list as $key => $val}
                          <option {$store_array.store_type == $val['storeclass_id'] ? 'selected' : ''} value="{$val['storeclass_id']}">{$val['storeclass_name']}</option>
                          {/foreach}
                          {/notempty}
                      </select>
                  </td>
                  <td class="vatop tips"></td>
              </tr>

              <!--有效期至-->
              <tr class="noborder">
                  <td class="w120"><label class="validation" for="store_name">{$Think.lang.period_to}:</label></td>
                  <td class="vatop rowform"><input type="text" value="{$store_array.store_endtime}" id="end_time" name="end_time" class="txt date"></td>
                  <td class="vatop tips">{$Think.lang.formart}</td>
              </tr>
              <!--余额-->
              <tr class="noborder">
                  <td class="required w120"><label class="validation" for="store_name">余额:</label></td>
                  <td class="vatop rowform"><input type="text" value="{$store_array.balance}" id="balance" name="balance" class="txt"></td>
                  <td class="vatop tips"></td>
              </tr>

              <!--状态-->
              <tr class="noborder">
                  <td class="w120"><label class="validation" for="store_name">{$Think.lang.state}:</label></td>
                  <td class="vatop rowform onoff"><label for="store_state1" class="cb-enable {if $store_array.store_state == '1'}selected{/if}" ><span>{$Think.lang.ds_open}</span></label>
                      <label for="store_state0" class="cb-disable {if $store_array.store_state == '0'}selected{/if}" ><span>{$Think.lang.ds_close}</span></label>
                      <input id="store_state1" name="store_state" {if $store_array.store_state == '1'}checked="checked"{/if} onclick="$('#tr_store_close_info').hide();" value="1" type="radio">
                      <input id="store_state0" name="store_state" {if $store_array.store_state == '0'}checked="checked"{/if} onclick="$('#tr_store_close_info').show();" value="0" type="radio"></td>
                  <td class="vatop tips"></td>
              </tr>

              <!--关闭原因-->
              <tr class="noborder" id="tr_store_close_info">
                  <td class="w120"><label class="validation" for="store_name">{$Think.lang.store_close_info}:</label></td>
                  <td class="vatop rowform"><textarea name="store_close_info" rows="6" class="tarea" id="store_close_info">{$store_array.store_close_info}</textarea></td>
                  <td class="vatop tips"></td>
              </tr>


              </tbody>
              <tfoot>
              <tr class="tfoot">
                  <td colspan="15"><input class="btn" type="submit" style="line-height: 30px;" value="{$Think.lang.ds_submit}"/></td>
              </tr>
              </tfoot>
          </table>
      </form>
      <form id="joinin_form" enctype="multipart/form-data" method="post" action="{:url('Wholesale/edit_save_joinin')}" style="display:none;">
          <input type="hidden" name="member_id" value="{$joinin_detail.member_id}" />
          {if $joinin_detail.store_type != 1}

          <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
              <thead>
                  <tr>
                      <th colspan="20">{$Think.lang.company_contact_information}</th>
                  </tr>
              </thead>
              <tbody>
                  <tr>
                      <th class="w150">{$Think.lang.company_name}：</th>
                      <td colspan="20"><input type="text" class="txt" name="company_name" value="{$joinin_detail.company_name}"></td>
                  </tr>
                  <tr>
                      <th>{$Think.lang.company_location}：</th>
                      <td><input type="hidden" name="company_address" id="company_address" value="{$joinin_detail.company_address}"></td>
                      <th>{$Think.lang.company_address}：</th>
                      <td><input type="text" class="txt w300" name="company_address_detail" value="{$joinin_detail.company_address_detail}"></td>
                      <th>{$Think.lang.registered_capital}：</th>
                      <td><input type="text" class="txt w72" name="company_registered_capital" value="{$joinin_detail.company_registered_capital}">&nbsp;{$Think.lang.ten_thousand}{$Think.lang.currency_zh} </td>
                  </tr>
                  <tr>
                      <th>{$Think.lang.contact_name}：</th>
                      <td><input type="text" class="txt" name="contacts_name" value="{$joinin_detail.contacts_name}"></td>
                      <th>{$Think.lang.contact_number}：</th>
                      <td><input type="text" class="txt" name="contacts_phone" value="{$joinin_detail.contacts_phone}"></td>
                      <th>{$Think.lang.e_mail}：</th>
                      <td><input type="text" class="txt" name="contacts_email" value="{$joinin_detail.contacts_email}"></td>
                  </tr>
              </tbody>
          </table>
          <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
              <thead>
                  <tr>
                      <th colspan="20">{$Think.lang.business_license_information}</th>
                  </tr>
              </thead>
              <tbody>
                  <tr>
                      <th class="w150">{$Think.lang.business_license_number}：</th>
                      <td><input type="text" class="txt" name="business_licence_number" value="{$joinin_detail.business_licence_number}">
                      </td>
                  </tr>

                  <tr>
                      <th>{$Think.lang.place_business_license}：</th>
                      <td><input type="hidden" name="business_licence_address" id="business_licence_address" value="{$joinin_detail.business_licence_address}"></td></tr><tr>

                      <th>{$Think.lang.validity_business_license}：</th>
                      <td><input type="text" class="txt" name="business_licence_start" id="business_licence_start" value="{$joinin_detail.business_licence_start}"> - <input type="text" class="txt" name="business_licence_end" id="business_licence_end" value="{$joinin_detail.business_licence_end}">
                      </td>
                  </tr>
                  <tr>
                      <th>{$Think.lang.legal_scope_business}：</th>
                      <td colspan="20"><input type="text" class="txt w300" name="business_sphere" value="{$joinin_detail.business_sphere}"></td>
                  </tr>
                  <tr>
                      <th>{$Think.lang.business_license}<br />{$Think.lang.electronic_version}：</th>
                      <td colspan="20">
                          {notempty name="joinin_detail.business_licence_number_electronic"}
                          <a data-lightbox="lightbox-image"  href="{:get_store_joinin_imageurl($joinin_detail['business_licence_number_electronic'])}"> <img src="{:get_store_joinin_imageurl($joinin_detail['business_licence_number_electronic'])}" height="100"/> </a>
                          <input class="w200" type="file" name="business_licence_number_electronic">
                          {/notempty}
                      </td>
                  </tr>
              </tbody>
          </table>

          <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
              <thead>
                  <tr>
                      <th colspan="20">{$Think.lang.bank_information}：</th>
                  </tr>
              </thead>
              <tbody>
                  <tr>
                      <th class="w150">{$Think.lang.bank_name}：</th>
                      <td><input type="text" class="txt w300" name="bank_account_name" value="{$joinin_detail.bank_account_name}"></td>
                  </tr><tr>
                      <th>{$Think.lang.company_bank_account}：</th>
                      <td><input type="text" class="txt w300" name="bank_account_number" value="{$joinin_detail.bank_account_number}"></td></tr>
                  <tr>
                      <th>{$Think.lang.name_branch_bank}：</th>
                      <td><input type="text" class="txt w300" name="bank_name" value="{$joinin_detail.bank_name}"></td>
                  </tr>
                  <tr>
                      <th>{$Think.lang.location_bank_account}：</th>
                      <td colspan="20"><input type="hidden" name="bank_address" id="bank_address" value="{$joinin_detail.bank_address}"></td>
                  </tr>

              </tbody>

          </table>
          <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
              <thead>
                  <tr>
                      <th colspan="20">{$Think.lang.settlement_account_information}：</th>
                  </tr>
              </thead>
              <tbody>
                  <tr>
                      <th class="w150">{$Think.lang.bank_name}：</th>
                      <td><input type="text" class="txt w300" name="settlement_bank_account_name" value="{$joinin_detail.settlement_bank_account_name}"></td>
                  </tr>
                  <tr>
                      <th>{$Think.lang.company_bank_account}：</th>
                      <td><input type="text" class="txt w300" name="settlement_bank_account_number" value="{$joinin_detail.settlement_bank_account_number}"></td>
                  </tr>
                  <tr>
                      <th>{$Think.lang.name_branch_bank}：</th>
                      <td><input type="text" class="txt w300" name="settlement_bank_name" value="{$joinin_detail.settlement_bank_name}"></td>
                  </tr>

                  <tr>
                      <th>{$Think.lang.location_bank_account}：</th>
                      <td><input type="hidden" name="settlement_bank_address" id="settlement_bank_address" value="{$joinin_detail.settlement_bank_address}"></td>
                  </tr>
              </tbody>

          </table>

          {else /}
          <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
              <thead>
                  <tr>
                      <th colspan="6">{$Think.lang.store_and_contact_info}</th>
                  </tr>
              </thead>
              <tbody>
                  <tr>
                      <th>{$Think.lang.company_name}：</th>
                      <td><input type="text" class="txt" name="company_name" value="{$joinin_detail.company_name}"></td>
                      <th>{$Think.lang.company_location}：</th>
                      <td><input type="hidden" name="company_address" id="company_address" value="{$joinin_detail.company_address}"></td>
                      <th>{$Think.lang.company_address}：</th>
                      <td colspan="3"><input type="text" class="txt w300" name="company_address_detail" value="{$joinin_detail.company_address_detail}"></td>
                  </tr>
                  <tr>
                      <th>{$Think.lang.legal_person}：</th>
                      <td><input type="text" class="txt" name="legal_person" value="{$joinin_detail.legal_person}"></td>
                      <th>{$Think.lang.legal_person_phone}：</th>
                      <td><input type="text" name="legal_person_phone" id="company_address" value="{$joinin_detail.legal_person_phone}"></td>
                      <th>{$Think.lang.contact_name}：</th>
                      <td colspan="3"><input type="text" class="txt w300" name="contacts_name" value="{$joinin_detail.contacts_name}"></td>
                  </tr>
                  <tr>
                      <th>{$Think.lang.contact_number}：</th>
                      <td><input type="text" class="txt" name="contacts_phone" value="{$joinin_detail.contacts_phone}"></td>
                      <th>{$Think.lang.contact_phone}：</th>
                      <td><input type="text" class="txt" name="contact_legal_phone" value="{$joinin_detail.contact_legal_phone}"></td>
                      <th>{$Think.lang.e_mail}：</th>
                      <td><input type="text" class="txt" name="contacts_email" value="{$joinin_detail.contacts_email}"></td>
                  </tr>
              </tbody>
          </table>
          <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
              <thead>
                  <tr>
                      <th colspan="20">{$Think.lang.business_license_information}</th>
                  </tr>
              </thead>
              <tbody>
                  <tr>
                      <th class="w150">{$Think.lang.business_license_number}：</th>
                      <td><input type="text" class="txt" name="business_licence_number" value="{$joinin_detail.business_licence_number}"></td></tr><tr>

                      <!-- <th class="w150">{$Think.lang.duty_paragraph}：</th>
                      <td><input type="text" class="txt" name="duty_paragraph" value="{$joinin_detail.duty_paragraph}"></td></tr><tr>

                      <th class="w150">{$Think.lang.credit_code}：</th>
                      <td><input type="text" class="txt" name="credit_code" value="{$joinin_detail.credit_code}"></td></tr><tr> -->

                      <th>{$Think.lang.place_business_license}：</th>
                      <td><input type="hidden" name="business_licence_address" id="business_licence_address" value="{$joinin_detail.business_licence_address}"></td></tr><tr>

                      <!--营业执照有效期-->
                      <th>{$Think.lang.validity_business_license}：</th>
                      <td><input type="text" class="txt" name="business_licence_start" id="business_licence_start" value="{$joinin_detail.business_licence_start}"> - <input type="text" class="txt" name="business_licence_end" id="business_licence_end" value="{$joinin_detail.business_licence_end}"></td>
                  </tr>
                  <tr>
                      <th>{$Think.lang.legal_scope_business}：</th>
                      <td colspan="20"><input type="text" class="txt w300" name="business_sphere" value="{$joinin_detail.business_sphere}"></td>
                  </tr>
                  <tr>
                      <th>{$Think.lang.business_license}<br />{$Think.lang.electronic_version}：</th>
                      <td colspan="20">
                          {notempty name="joinin_detail.business_licence_number_electronic"}
                          <a data-lightbox="lightbox-image"  href="{:get_store_joinin_imageurl($joinin_detail['business_licence_number_electronic'])}"> <img src="{:get_store_joinin_imageurl($joinin_detail['business_licence_number_electronic'])}" height="100"/> </a>
                           {/notempty}
                          <input class="w200" type="file" name="business_licence_number_electronic">
                         
                      </td>
                  </tr>
              </tbody>
          </table>


          <table border="0" cellpadding="0" cellspacing="0" class="store-joinin ds-default-table">
              <thead>
                  <tr>
                      <th colspan="2">{$Think.lang.store_alipay_info}：</th>
                  </tr>
              </thead>
              <tbody>
                  <tr>
                      <th>{$Think.lang.bank_account_name}：</th>
                      <td><input type="text" class="txt w300" name="settlement_bank_account_name" value="{$joinin_detail.settlement_bank_account_name}"></td>
                  </tr>
                  <tr>
                      <th>{$Think.lang.bank_account_number}：</th>
                      <td><input type="text" class="txt w300" name="settlement_bank_account_number" value="{$joinin_detail.settlement_bank_account_number}"></td>
                  </tr>

                  <tr>
                      <th>{$Think.lang.bank_name}：</th>
                      <td><input type="text" class="txt w300" name="settlement_bank_name" value="{$joinin_detail.settlement_bank_name}"></td>
                  </tr>

                  <tr>
                      <th>{$Think.lang.bank_address}：</th>
                      <td><input type="text" class="txt w300" name="settlement_bank_address" value="{$joinin_detail.settlement_bank_address}"></td>
                  </tr>
              </tbody>

          </table>
   {/if}
          <div><input class="btn" type="submit" style="line-height: 30px;"  value="{$Think.lang.ds_submit}"/></div>
      </form>
      <form id="credit_num_form" action="{:url('Wholesale/deduct')}" method="post" style="display:none;">
          <input type="hidden" name="store_id" value="{$store_array.store_id}" />
          <table class="ds-default-table">
              <tbody>
              <!--账期额度-->
              <tr class="noborder">
                  <td class="required w120"><label class="validation" for="store_name">{$Think.lang.credit_num}:</label></td>
                  <td class="vatop rowform"><input type="text" value="{$store_array.credit_num}" id="credit_num" name="credit_num" class="txt"></td>
                  <td class="vatop tips"></td>
              </tr>
              <!--账期天数-->
              <tr class="noborder">
                  <td class="required w120"><label class="validation" for="store_name">{$Think.lang.credit_day}:</label></td>
                  <td class="vatop rowform"><input type="text" value="{$store_array.credit_day}" id="credit_day" name="credit_day" class="txt"></td>
                  <td class="vatop tips"></td>
              </tr>

              <!--期初未开票金额-->
              <tr class="noborder">
                  <td class="required w120"><label class="validation" for="store_name">{$Think.lang.invocie_money}:</label></td>
                  <td class="vatop rowform"><input type="text" value="{$store_array.invocie_money}" id="invocie_money" name="invocie_money" class="txt"></td>
                  <td class="vatop tips"></td>
              </tr>

              <!--期初未欠款金额-->
              <tr class="noborder">
                  <td class="required w120"><label class="validation" for="store_name">{$Think.lang.debt_money}:</label></td>
                  <td class="vatop rowform"><input type="text" value="{$store_array.debt_money}" id="debt_money" name="debt_money" class="txt"></td>
                  <td class="vatop tips"></td>
              </tr>
              <tr>
                  <td><input class="btn" type="submit" style="line-height: 30px;" value="{$Think.lang.ds_submit}"/></td>
              </tr>

              </tbody>

          </table>
      </form>
</div>
</div>
<link rel="stylesheet" href="{$Think.PLUGINS_SITE_ROOT}/js/jquery.lightbox/css/lightbox.min.css">
<script src="{$Think.PLUGINS_SITE_ROOT}/js/jquery.lightbox/js/lightbox.min.js"></script>
<script type="text/javascript">
$(function(){
    $("#company_address").ds_region();
    $("#business_licence_address").ds_region();
    $("#bank_address").ds_region();
    $("#settlement_bank_address").ds_region();
    $('#end_time').datepicker({dateFormat: 'yy-mm-dd'});

    /*更换成可以选择月份 年份的时间控件*/
    /*$('#business_licence_start').datepicker({dateFormat: 'yy-mm-dd'});
    * $('#business_licence_end').datepicker({dateFormat: 'yy-mm-dd'});
    * */
    $('#business_licence_start').datepicker({dateFormat: 'yy-mm-dd',   changeMonth: true,
        changeYear: true});
    $('#business_licence_end').datepicker({dateFormat: 'yy-mm-dd',   changeMonth: true,
        changeYear: true});



    $('input[name=store_state][value={$store_array.store_state}]').trigger('click');


    $('#store_form').validate({
        errorPlacement: function(error, element){
            error.appendTo(element.parent().parent().find('td:last'));
            // error.appendTo(element.parentsUntil('tr').parent().prev().find('td:first'));
        },
        rules : {
             store_name: {
                 required : true,
                 remote : "{:url('Wholesale/ckeck_store_name',['store_id'=>$store_array.store_id])}"
              },
              balance : {
                  required: true,
                  digits:true,
              }
        },
        messages : {
            store_name: {
                required: '{$Think.lang.please_input_store_name}',
                remote : '{$Think.lang.store_name_exists}'
            },
            balance : {
                 required: '余额不能为空',
                 digits : '请输入正确的余额',
            }
        }
    });
    $('#joinin_form').validate({
        errorPlacement: function(error, element){
            error.appendTo(element.parentsUntil('tr').parent().find('td:last'));
        },
        rules : {
              business_licence_start:{
                required: true,
              },
              business_licence_end:{
                required: true,
              }
        },
        messages : {
            business_licence_start:{
                required: '{$Think.lang.business_licence_start_required}',
            },
            business_licence_end:{
                required: '{$Think.lang.business_licence_start_required}',
            }
        }
    });



    $('div[dstype="editStoreContent"] > ul').find('li').click(function(){
        $(this).addClass('current').siblings().removeClass('current');
        var _index = $(this).index();
        var _form = $('div[dstype="editStoreContent"]').find('form');
        _form.hide();
        _form.eq(_index).show();
    });
});
</script>
